//package com.juneng.interceptor;
//
//import cn.hutool.core.util.StrUtil;
//import com.juneng.constant.Constant;
//import com.juneng.exception.AuthException;
//import com.juneng.exception.ValidateException;
//import com.juneng.utils.ServletUtils;
//import com.juneng.vo.UserVo;
//import org.springframework.web.servlet.HandlerInterceptor;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//
///**
// * @ClassName: LoginInterceptor
// * @Description: 拦截未登录的用户
// * @author: zds
// * @date: 2019/5/7  11:21
// */
//public class LoginInterceptor implements HandlerInterceptor {
//
//    @Override
//    public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
//                             Object handler) throws ValidateException {
//        String userId = ServletUtils.getUserId();
//
//        String token = ServletUtils.getToken();
//        if (StrUtil.isEmpty(userId) || StrUtil.isEmpty(token) || Constant.NULL_STR.equals(userId) || Constant.NULL_STR.equals(token)) {
//            throw new AuthException();
//        }
//
//        UserVo userVO = ServletUtils.getUser();
//        if (!token.equals(userVO.getToken())) {
//            throw new AuthException();
//        }
//        return true;
//    }
//
//}
